<template>
  <div>
    <div style="height: 70px;width: 100%;background: #aeb3c5;text-align: center">
      <span style="color: white;line-height: 70px;font-size: 25px">采购信息查询</span>
    </div>

    <!--表格-->
    <div>
      <el-table :data="cutBean.records" style="width: 100%">
        <el-table-column prop="supplierBean.name" label="供应商名称"/>
        <el-table-column prop="user" label="采购员"/>
        <el-table-column prop="date" label="采购时间"/>
        <el-table-column fixed="right" label="操作" width="220">
          <template #default="scope">
            <el-button type="success" @click="show(scope.row)">查看采购详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页查询-->
      <div style="margin-top: 50px">
        <div style="display: flex;justify-content: space-around;margin-top: 20px">
          <div style="width: 350px;">供应商:
            <el-input v-model="findObj.name" style="width: 250px"/>
          </div>
          <div>起始日期
            <el-date-picker
                v-model="findObj.startDate"
                type="date"
                placeholder="选择日期"
                value-format="YYYY-MM-DD"
            />
          </div>
          <div>结束日期
            <el-date-picker
                v-model="findObj.endDate"
                type="date"
                placeholder="选择日期"
                value-format="YYYY-MM-DD"
            />
          </div>
          <div>
            <el-button type="primary" @click="findByItem(1)">查询</el-button>
          </div>
        </div>

      </div>
      <el-pagination
          v-model:currentPage="cutBean.current"
          v-model:page-size="cutBean.size"
          background
          layout="prev, pager, next, jumper"
          :total="cutBean.total"
          @current-change="findByItem"
          style="margin-top: 50px"
      />
    </div>

    <!--查看弹出框-->
    <el-dialog
        v-model="infoVisible"
        title="供应商信息详情"
        width="50%"
    >
      <p>供应商名称：{{infoObj.supplierBean.name}}</p><br>
      <p>采购员：{{infoObj.user}}</p><br>
      <p>采购时间：{{infoObj.date}}</p><br>

      <el-table :data="buyerInfo.buyerInfoList" style="width: 70%">
        <el-table-column prop="product.name" label="供应商名称"/>
        <el-table-column prop="product.brand" label="品牌"/>
        <el-table-column prop="buyMoney" label="采购价"/>
        <el-table-column prop="num" label="采购数量"/>
      </el-table>
      <template #footer>
      <span class="dialog-footer">
        <el-button @click="infoVisible = false">确定</el-button>
      </span>
      </template>
    </el-dialog>


  </div>

</template>

<script>
import axios from "axios";

export default {
  data() {
    return {
      cutBean: {},
      findObj:{},
      infoObj:{},
      dialogVisible: false,
      infoVisible:false,
      buyerInfo:{},
    }
  },
  methods:{
    findByItem(pageNO){
      this.findObj.pageNO=pageNO;
      axios.get("/project/buyer/findByItem",{
        params:this.findObj
      }).then(resp=>{
        this.cutBean=resp.data;
      })
    },
    show(obj){
      this.infoVisible=true;
      this.infoObj=obj;
      axios.get("/project/buyer/findById",{
        params:{
          buyerId:obj.id
        }
      }).then(resp=>{
        this.buyerInfo=resp.data
      })
    },

  },
  created() {
    this.findByItem(1);
  }
}
</script>

<style scoped>

</style>